package com.nbwyctf.helper.utils;

import java.text.Collator;
import java.util.Comparator;

/**
 * @author chetaifu
 */
public class StringUtil {
    /**
     * 中文排序
     */
    public static int compareChinese(String o1, String o2){
        Comparator<Object> compare = Collator.getInstance(java.util.Locale.CHINA);
        o1 = o1.replaceAll("一", "11");
        o1 = o1.replaceAll("二", "22");
        o1 = o1.replaceAll("三", "33");
        o1 = o1.replaceAll("四", "44");
        o1 = o1.replaceAll("五", "55");
        o1 = o1.replaceAll("六", "66");
        o1 = o1.replaceAll("七", "77");
        o1 = o1.replaceAll("八", "88");
        o1 = o1.replaceAll("九", "99");
        o2 = o2.replaceAll("一", "11");
        o2 = o2.replaceAll("二", "22");
        o2 = o2.replaceAll("三", "33");
        o2 = o2.replaceAll("四", "44");
        o2 = o2.replaceAll("五", "55");
        o2 = o2.replaceAll("六", "66");
        o2 = o2.replaceAll("七", "77");
        o2 = o2.replaceAll("八", "88");
        o2 = o2.replaceAll("九", "99");
        return compare.compare(o1,o2);
    }
}
